package com.ww.disruptor.handler;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;
import com.ww.disruptor.event.ProductEvent;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
public class MultiThanHandler implements EventHandler<ProductEvent>, WorkHandler<ProductEvent> {

    private String name;

    public MultiThanHandler(String name) {
		super();
		this.name = name;
	}

	@Override
    public void onEvent(ProductEvent event, long sequence, boolean endOfBatch) throws Exception {
        System.out.println("广播模式，消费者" + name + "，当前线程" + Thread.currentThread().getName() + "处理event" + event.getUid());
    }

    @Override
    public void onEvent(ProductEvent event) throws Exception {
        System.out.println("集群模式，消费者" + name + "，当前线程" + Thread.currentThread().getName() + "处理event" + event.getUid());
    }

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
